package cn.codergege.gradle.plugin

import cn.codergege.gradle.plugin.kotlin.*
import org.gradle.api.Plugin
import org.gradle.api.Project

open class StagePlugin: Plugin<Project> {

    override fun apply(project: Project?) {
        // Basic stage
        val stage = project?.tasks?.create("stage", Stage::class.java) {
            // 设置任务配置默认值
            it.group = "stage"
            it.description = "生成基本架构: main, test 目录"
        }
        val ktBasicStage = project?.tasks
            ?.create("ktBasic", KtBasicStage::class.java) {
                it.group = "stage"
                it.description = "Kotlin 基本架构"
            }
        val ktJavaBasicStage = project?.tasks
            ?.create("ktJavaBasic", KtJavaBasicStage::class.java) {
                it.group = "stage"
                it.description = "Kotlin + Java 基本架构"
            }
        val ktBootBasicStage = project?.tasks
            ?.create("ktBootBasic", KtBootBasicStage::class.java) {
                it.group = "stage"
                it.description = """
                    >Kotlin + Spring Boot 基本架构:
                    >kotlin, java
                    >spring boot: data-jpa
                    >H2, mysql, druid
                    """.trimMargin(">")
            }
        val ktBootWebBasicStage = project?.tasks
            ?.create("ktBootWebBasic", KtBootWebBasicStage::class.java) {
                it.group = "stage"
                it.description = """
                    >Kotlin + Spring Boot 基本架构:
                    >kotlin, java
                    >spring boot: web, data-jpa
                    >H2, mysql, druid
                    """.trimMargin(">")
            }
        val ktBootWebThymeleafStage = project?.tasks
            ?.create("ktBootWebThymeleaf", KtBootWebThymeleafStage::class.java) {
                it.group = "stage"
                it.description = """
                    >基本架构:
                    >Ktolin
                    >Spring Boot: web, data-jpa, thymeleaf
                    >数据库: H2, Mysql, druid, querydsl
                    >前端: thymeleaf, jquery, bootstrap, font-awesome, bp
                    """.trimMargin(">")
            }

        // 设置任务依赖
//        ktBasicStage?.dependsOn(stage) // 不需要这个
    }

}